package cn.kgc.springcloud.controller;

import cn.kgc.springcloud.entity.City;
import cn.kgc.springcloud.service.CityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author: mosin
 * @version: v1.0  2022/6/15
 */
@RestController
@RequestMapping("cities")
public class CityController {

    @Autowired
    private CityService cityService;

    @GetMapping
    public List<City> getAll(){
        return   cityService.selectAll();
    }

    @PostMapping
    public City add(@RequestBody City city){
        return  cityService.addCity(city);
    }

    @GetMapping("{id}")
    public City getById(@PathVariable("id") Integer id){
        return cityService.getById(id);
    }

}
